<%@ Page Language="C#" Theme="Defaultsys" AutoEventWireup="true" CodeFile="CallFinishedPageField.aspx.cs"
    Inherits="CallFinishedPageField" Title="Rapport Plan System - Call finished page field"
    MasterPageFile="~/MasterPage.master" EnableEventValidation="false" %>

<%@ MasterType VirtualPath="~/MasterPage.master" %>
<asp:Content runat="server" ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1">

    <script type="text/javascript" language="javascript">
        function FieldTypeChange(obj)
        {
        
            var divComboboxValues = document.getElementById("ctl00_ContentPlaceHolder1_comboboxValuesId");            
            var cmb = document.getElementById("ctl00_ContentPlaceHolder1_cmbFieldType");
              
            switch (cmb[cmb.selectedIndex].value)
            {
                case "1":
                    divComboboxValues.style.display = "inline";
                    break;
                default:
                    divComboboxValues.style.display = "none";
                    break;
            }
        }
        
        
      
        function AddValue()
        {            
            var newValue = document.getElementById("ctl00_ContentPlaceHolder1_txtComboboxValue").value;
            var o = document.createElement("option");
            o.text = newValue;
            o.value = newValue;
            document.getElementById("ctl00$ContentPlaceHolder1$lstComboboxValues").add(o);
            
            document.getElementById("ctl00_ContentPlaceHolder1_txtComboValues").value += newValue+";";            
            document.getElementById("ctl00_ContentPlaceHolder1_txtComboboxValue").value = "";
            document.getElementById("ctl00_ContentPlaceHolder1_txtComboboxValue").focus();
            
            return false;
        }       
        
        function RemoveValue()
        {              
            var lst = document.getElementById("ctl00_ContentPlaceHolder1_lstComboboxValues");
            if (lst.selectedIndex != -1)
            {                
                lst.remove(lst.selectedIndex);
            }
            
            document.getElementById("ctl00_ContentPlaceHolder1_txtComboValues").value = "";
            for (i=0; i<lst.options.length; i++)
            {
                document.getElementById("ctl00_ContentPlaceHolder1_txtComboValues").value += lst.options[i].value+";";
            }
                        
            return false;
        }    
        
    </script>

    <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
            <td class="contTable">
                <table>
                    <tr>
                        <td>
                            Name:</td>
                        <td style="width: 289px">
                            <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtName"
                                CssClass="error" ErrorMessage="Name is required" SetFocusOnError="True" Display="Dynamic">*</asp:RequiredFieldValidator></td>
                        <dt>&nbsp;</dt></tr>
                    <tr>
                        <td>
                            Type:</td>
                        <td>
                            <asp:DropDownList ID="cmbFieldType" runat="server" Width="155px">
                                <asp:ListItem Value="0">textbox</asp:ListItem>
                                <asp:ListItem Value="2">checkbox</asp:ListItem>
                                <asp:ListItem Value="1">combobox</asp:ListItem>
                                <asp:ListItem Value="3">datetime picker</asp:ListItem>
                                <asp:ListItem Value="4">textarea</asp:ListItem>
                            </asp:DropDownList></td>
                    </tr>
                    <tr id="comboboxValuesId" style="display: none" runat="server">
                        <td valign="top">
                            Comobobox values:</td>
                        <td>
                            <table>
                                <tr>
                                    <td style="width: 262px">
                                        <asp:TextBox ID="txtComboboxValue" runat="server"></asp:TextBox>
                                        <asp:Button ID="btnAddValue" runat="server" Text="Add" /></td>
                                </tr>
                                <tr>
                                    <td style="width: 262px">
                                        <asp:ListBox ID="lstComboboxValues" runat="server" Width="282px"></asp:ListBox></td>
                                </tr>
                                <tr>
                                    <td style="width: 262px">
                                        <asp:Button ID="btnDelete" runat="server" Text="Remove" /></td>
                                </tr>
                            </table>
                            <asp:HiddenField ID="txtComboValues" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="1" align="left">
                            <asp:Button ID="btnSave" runat="server" OnClick="Save" Text="Save" />
                            <asp:Button ID="btnCancel" runat="server" OnClick="Cancel" Text="Cancel" CausesValidation="false" /></td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtName"
                                CssClass="error" ErrorMessage="(*)Name is required" SetFocusOnError="True" Display="Dynamic"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</asp:Content>
